/*
 * edge.h
 *
 *      Author: Jerome RD Soine and Christoph A Brand
 *      Institution: Schwarz goup, Institute for Theoretical Physics, Heidelberg University, Germany
 */

#ifndef EDGE_H
#define EDGE_H

#include "vertex.h"
#include <vector>
#include <iostream>
#include "map"


using namespace std;

class Edge
  {
  private:
    Vertex* head;
    Vertex* tail;
    int index;
    double restlength;
    vector<Triangle*> adjacentTriangles;
    map<int,double> numericalAttributes;

  public:
    Edge(Vertex* head, Vertex* tail);

    bool operator==(Edge & e) const;

    Vertex* getHead(){ return head; };
    Vertex* getTail(){ return tail; };
    Vertex toVector(){ return *head-*tail; };

    const bool connectsVertices(Vertex *V1, Vertex* V2) const;
    const bool connectsVerticesInOrder(Vertex *V1, Vertex* V2) const;
    const bool containsVertex(Vertex *V1) const;

    int getIndex() {return index;};
    void setIndex(int i) {index = i; };

    double getRestlength() { return restlength; };
    void setRestlength( double RESTLENGTH ) { restlength = RESTLENGTH; };

    vector<Triangle*>* getAdjacentTriangles(){ return &adjacentTriangles; };
    Triangle * getSecondAdjacentTriangle(Triangle * firstAdjacentTriangle);
    Vertex * getSecondTip(Vertex * firstTip);
    double getValueOfAttribute(int fieldname){return numericalAttributes.find(fieldname)->second;};
    void putNumericalAttribute(int fieldname, double attr){numericalAttributes[fieldname] = attr;};
    bool isEndlineOfSF();
    bool intersects(Edge & e);
    Vertex * getEndpointOfFiber();
   };

#endif // EDGE_H

/*
 * cout << "adjT: " << adjacentTriangles.size() <<endl;
 */
